﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace KinectApplication
{
    public static class HandGestureReader
    {
        // GesturereReader adjustments (don´t dick around with these or you may ruin the gesturedata collected)
        public const int PicWidth = 20;
        public const int PicHeight = 30;

        // Gestures
        // TODO: we should have some fancy code to save and load lists of these gestures (the file could say what enum the gesture is and the data below)
        private static short[] rightLDefault = new short[]
                    {
                        500, 500, 500, 500, 1000, 1000, 1000, 1000, 500, 500, 500, 500, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 500, 500, 500, 500, 1000, 1000, 1000, 1000, 500, 500, 500, 500, 0, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 500, 500, 500, 500, 1000, 1000, 1000, 1000, 0, 500, 500, 500, 0, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 500, 500, 500, 1000, 1000, 1000, 1000, 500, 0, 0, 500, 0, 0, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 500, 500, 500, 1000, 1000, 1000, 1000, 500, 0, 0, 0, 0, 0, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 500, 0, 0, 0, 0, 0, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 500, 0, 0, 0, 0, 0, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 500, 500, 500, 0, 0, 0, 0, 0, 0, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 1000, 1000, 1000, 1000, 1000, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 1000, 1000, 1000, 1000, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 1000, 1000, 500, 500, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 500, 500, 500, 500, 500, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 500, 500, 500, 500, 500, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 500, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 500, 500, 500, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 500, 500, 500, 1000, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 500, 500, 500, 1000, 1000, 1000, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 500, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 500, 0, 0, 0, 0, 0, 0, 0, 500, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 500, 500, 500, 500, 500, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000
                    };

        private static short[] rightEvulDefault = new short[]
                    {
                        1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 500, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 500, 1000, 1000, 1000, 500, 0, 500, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 500, 500, 1000, 1000, 1000, 500, 0, 0, 500, 500, 500, 1000, 1000, 1000, 1000, 500, 500, 1000, 1000, 1000, 500, 500, 1000, 1000, 1000, 500, 0, 0, 500, 500, 500, 1000, 1000, 1000, 500, 500, 500, 1000, 1000, 1000, 500, 500, 1000, 1000, 1000, 500, 0, 0, 500, 500, 500, 1000, 1000, 500, 500, 500, 500, 1000, 1000, 1000, 500, 500, 1000, 1000, 1000, 0, 0, 0, 1000, 500, 500, 500, 500, 500, 500, 500, 1000, 1000, 1000, 500, 0, 500, 1000, 1000, 1000, 0, 0, 0, 1000, 500, 500, 500, 500, 500, 500, 500, 1000, 1000, 1000, 500, 0, 500, 1000, 1000, 500, 0, 0, 0, 1000, 500, 500, 500, 500, 500, 500, 500, 1000, 1000, 500, 500, 0, 500, 500, 500, 0, 0, 0, 0, 1000, 500, 500, 500, 0, 0, 500, 500, 1000, 1000, 500, 0, 0, 500, 500, 500, 0, 0, 0, 500, 1000, 500, 500, 0, 0, 0, 0, 500, 500, 500, 0, 0, 0, 500, 500, 500, 0, 0, 0, 500, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 0, 0, 0, 0, 500, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1000, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1000, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1000, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1000, 1000, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 1000, 1000, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 1000, 1000, 1000, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 1000, 1000, 1000, 500, 500, 500, 500, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 1000, 1000, 1000, 1000, 1000, 500, 500, 500, 500, 0, 0, 0, 0, 0, 0, 0, 0, 500, 500, 1000, 1000, 1000, 1000, 1000, 1000, 500, 500, 500, 500, 500, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 500, 500, 500, 500, 0, 0, 0, 0, 0, 0, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 500, 500, 0, 0, 0, 0, 0, 0, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 500, 500, 500, 0, 0, 0, 500, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 500, 500, 500, 500, 500, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000
                    };

        private static short[] rightPointDefault = new short[]
                    {
                        500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 1000, 500, 500, 500, 500, 500, 500, 500, 1000, 1000, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 500, 500, 500, 500, 500, 500, 500, 500, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 500, 500, 500, 500, 500, 500, 500, 500, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 500, 500, 0, 500, 500, 500, 500, 500, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 500, 500, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 500, 500, 500, 500, 0, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 1000, 1000, 1000, 1000, 1000, 500, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 1000, 1000, 1000, 1000, 1000, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 1000, 1000, 1000, 500, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 1000, 1000, 500, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 1000, 1000, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 1000, 1000, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 1000, 1000, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 1000, 1000, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 1000, 1000, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 1000, 1000, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 1000, 1000, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 1000, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 500, 1000, 1000, 1000, 0, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 500, 1000, 1000, 1000, 1000, 0, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 500, 500, 1000, 1000, 1000, 1000, 0, 0, 500, 0, 0, 0, 0, 0, 0, 0, 0, 500, 500, 500, 500, 1000, 1000, 1000, 1000, 1000, 0, 0, 500, 0, 0, 0, 0, 0, 0, 0, 500, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 500, 0, 500, 0, 0, 0, 0, 0, 500, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 500, 500, 500, 0, 0, 0, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000
                    };

        private static short[] leftLDefault = new short[]
                    {
                        1000, 1000, 1000, 1000, 1000, 1000, 1000, 500, 500, 500, 500, 500, 1000, 1000, 1000, 1000, 500, 500, 500, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 0, 500, 500, 500, 500, 1000, 1000, 1000, 1000, 500, 500, 500, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 0, 500, 500, 500, 0, 1000, 1000, 1000, 1000, 500, 500, 500, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 0, 0, 500, 0, 0, 500, 1000, 1000, 1000, 1000, 500, 500, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 0, 0, 0, 0, 0, 500, 1000, 1000, 1000, 1000, 500, 500, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 0, 0, 0, 0, 0, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 0, 0, 0, 0, 0, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 0, 0, 0, 0, 0, 0, 500, 500, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 500, 500, 1000, 1000, 1000, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 500, 500, 500, 500, 500, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 500, 500, 500, 500, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 500, 500, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 500, 500, 500, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 500, 1000, 500, 500, 500, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1000, 1000, 1000, 1000, 1000, 1000, 500, 500, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 500, 500, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 500, 500, 500, 500, 500, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000
                    };

        private static short[] leftEvulDefault = new short[]
                    {
                        1000, 500, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 500, 500, 0, 500, 1000, 1000, 1000, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 500, 0, 0, 500, 1000, 1000, 1000, 500, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 500, 0, 0, 500, 1000, 1000, 1000, 500, 500, 1000, 1000, 1000, 500, 500, 1000, 1000, 1000, 1000, 500, 500, 500, 0, 0, 500, 1000, 1000, 1000, 500, 500, 1000, 1000, 1000, 500, 500, 500, 1000, 1000, 1000, 500, 500, 1000, 0, 0, 0, 1000, 1000, 1000, 500, 500, 1000, 1000, 1000, 500, 500, 500, 500, 1000, 1000, 500, 500, 1000, 0, 0, 0, 1000, 1000, 1000, 500, 0, 500, 1000, 1000, 1000, 500, 500, 500, 500, 500, 500, 500, 1000, 0, 0, 0, 500, 1000, 1000, 500, 0, 500, 1000, 1000, 1000, 500, 500, 500, 500, 500, 500, 500, 1000, 0, 0, 0, 0, 500, 500, 500, 0, 500, 500, 1000, 1000, 500, 500, 500, 500, 500, 500, 500, 1000, 500, 0, 0, 0, 500, 500, 500, 0, 0, 500, 1000, 1000, 500, 500, 0, 0, 500, 500, 500, 1000, 500, 0, 0, 0, 500, 500, 500, 0, 0, 0, 500, 500, 500, 0, 0, 0, 0, 500, 500, 1000, 500, 0, 0, 0, 0, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1000, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1000, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1000, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1000, 1000, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1000, 1000, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1000, 1000, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1000, 1000, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1000, 1000, 1000, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1000, 1000, 1000, 1000, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 1000, 1000, 1000, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 1000, 1000, 1000, 1000, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 500, 500, 500, 500, 1000, 1000, 1000, 1000, 1000, 500, 500, 0, 0, 0, 0, 0, 0, 0, 0, 500, 500, 500, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 500, 0, 0, 0, 0, 0, 0, 0, 500, 500, 500, 500, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 500, 0, 0, 0, 0, 0, 0, 500, 500, 500, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 0, 0, 0, 0, 0, 0, 500, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 500, 500, 0, 0, 0, 500, 500, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 500, 500, 500, 500, 500, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000
                    };

        private static short[] leftPointDefault = new short[]
                    {
                        1000, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 1000, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 1000, 1000, 500, 500, 500, 500, 500, 500, 500, 1000, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 500, 500, 500, 500, 500, 500, 500, 500, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 500, 500, 500, 500, 500, 500, 500, 500, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 500, 500, 500, 500, 500, 500, 0, 500, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 500, 0, 0, 0, 0, 0, 0, 0, 500, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 500, 0, 0, 0, 0, 0, 0, 0, 0, 500, 500, 500, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 1000, 1000, 1000, 1000, 1000, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 500, 1000, 1000, 1000, 1000, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 500, 1000, 1000, 1000, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 1000, 1000, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 1000, 1000, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 1000, 1000, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 1000, 1000, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 1000, 1000, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 1000, 1000, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 1000, 1000, 500, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1000, 1000, 1000, 1000, 500, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 0, 1000, 1000, 1000, 1000, 500, 500, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 0, 1000, 1000, 1000, 1000, 1000, 500, 500, 500, 500, 0, 0, 0, 0, 0, 0, 0, 0, 500, 0, 0, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 500, 500, 0, 0, 0, 0, 0, 0, 0, 500, 0, 0, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 500, 500, 0, 0, 0, 0, 0, 500, 0, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 500, 0, 0, 0, 500, 500, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000
                    };
        
        // Old gesture data
        // Standard hand (can´t tell from fist)
        //0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 500, 500, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 1000, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1000, 1000, 1000, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1000, 1000, 1000, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 500, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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1000, 1000, 1000, 1000, 1000, 1000, 0, 500, 500, 1000, 500, 0, 0, 0, 0, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000
        // Fist
        //0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 1000, 1000, 1000, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 500, 1000, 1000, 1000, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 1000, 1000, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1000, 1000, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1000, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1000, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1000, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 500, 1000, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 500, 1000, 1000, 1000, 500, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 500, 1000, 1000, 1000, 1000, 1000, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 500, 0, 0, 0, 0, 0, 500, 500, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000
        // RightLDefault old (clearer gesture but hard to do)
        //1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 0, 0, 0, 0, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 0, 0, 0, 0, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 0, 0, 0, 0, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 0, 0, 0, 0, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 500, 0, 0, 0, 0, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 500, 500, 0, 0, 0, 0, 0, 0, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 500, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 500, 500, 500, 1000, 1000, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1000, 1000, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1000, 1000, 1000, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 1000, 1000, 1000, 1000, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 500, 0, 0, 0, 0, 0, 0, 0, 500, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 0, 0, 0, 0, 0, 0, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 0, 0, 0, 0, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 500, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000
        // RightEvulDefault old (Clearer gesture but hard to do)
        //1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 500, 500, 500, 500, 500, 0, 0, 0, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 500, 0, 0, 500, 500, 0, 0, 0, 500, 1000, 500, 0, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 500, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 0, 0, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 500, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 0, 0, 0, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 500, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 0, 0, 0, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 500, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 0, 0, 0, 500, 1000, 1000, 1000, 1000, 1000, 1000, 500, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 0, 0, 0, 500, 1000, 1000, 1000, 1000, 1000, 1000, 500, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 0, 0, 0, 0, 1000, 1000, 1000, 1000, 1000, 1000, 500, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 0, 0, 0, 0, 500, 1000, 1000, 1000, 1000, 1000, 500, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 0, 0, 0, 0, 0, 500, 500, 500, 500, 500, 0, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1000, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1000, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1000, 1000, 1000, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 1000, 1000, 1000, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1000, 1000, 1000, 1000, 1000, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 500, 0, 0, 0, 0, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000


        // Debugging only!
        private static short[] emptyHand = new short[]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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
                    };

        public static bool IdentifyGesture(bool isRight, short[] resizedHandArray, Hand targetHand)
        {
            short[] lDefault;
            short[] evulDefault;
            short[] pointDefault;

            if (isRight)
            {
                lDefault = rightLDefault;
                evulDefault = rightEvulDefault;
                pointDefault = rightPointDefault;
            }
            else
            {
                lDefault = leftLDefault;
                evulDefault = leftEvulDefault;
                pointDefault = leftPointDefault;
            }

            // TODO: replace with more dynamic list to sort through?
            double handHits = 0;
            double handTotal = 0;
            double fistHits = 0;
            double fistTotal = 0;
            double evulHits = 0;
            double evulTotal = 0;

            for (int i = 0; i < resizedHandArray.Length; ++i)
            {
                if (resizedHandArray[i] > 500)
                {
                    if (lDefault[i] == 1000)
                        ++handHits;
                    if (pointDefault[i] == 1000)
                        ++fistHits;
                    if (evulDefault[i] == 1000)
                        ++evulHits;
                }
                else // hand array has a small value
                {
                    if (lDefault[i] == 0)
                        ++handHits;
                    if (pointDefault[i] == 0)
                        ++fistHits;
                    if (evulDefault[i] == 0)
                        ++evulHits;
                }

                if (lDefault[i] != 500)
                {
                    ++handTotal;
                }
                if (pointDefault[i] != 500)
                {
                    ++fistTotal;
                }
                if (evulDefault[i] != 500)
                {
                    ++evulTotal;
                }
            }

            double handAccuracy = handHits / handTotal;
            double fistAccuracy = fistHits / fistTotal;
            double evulAccuracy = evulHits / evulTotal;

#if DEBUG
            if (false) // !isRight
            {
                if (handAccuracy > fistAccuracy)
                {
                    if (handAccuracy > evulAccuracy)
                    {
                        if (handAccuracy > ReachMouseInput.requiredGestureAccuracy)
                            Debugging.ShowHand(lDefault, PicWidth, PicHeight);
                        else
                            Debugging.ShowHand(resizedHandArray, PicWidth, PicHeight);
                            //Debugging.ShowHand(emptyHand, PicWidth, PicHeight);
                    }
                    else
                    {
                        if (evulAccuracy > ReachMouseInput.requiredGestureAccuracy)
                            Debugging.ShowHand(evulDefault, PicWidth, PicHeight);
                        else
                            Debugging.ShowHand(resizedHandArray, PicWidth, PicHeight);
                            //Debugging.ShowHand(emptyHand, PicWidth, PicHeight);
                    }
                }
                else // fist greater than hand
                {
                    if (fistAccuracy > evulAccuracy)
                    {
                        if (fistAccuracy > ReachMouseInput.requiredGestureAccuracy)
                            Debugging.ShowHand(pointDefault, PicWidth, PicHeight);
                        else
                            Debugging.ShowHand(resizedHandArray, PicWidth, PicHeight);
                            //Debugging.ShowHand(emptyHand, PicWidth, PicHeight);
                    }
                    else
                    {
                        if (evulAccuracy > ReachMouseInput.requiredGestureAccuracy)
                            Debugging.ShowHand(evulDefault, PicWidth, PicHeight);
                        else
                            Debugging.ShowHand(resizedHandArray, PicWidth, PicHeight);
                            //Debugging.ShowHand(emptyHand, PicWidth, PicHeight);
                    }
                }
            }
#endif

            // High and low gestures, still needed?
            if ((handAccuracy >= evulAccuracy) && (handAccuracy >= fistAccuracy))
            { // hand (L) is highest
                targetHand.HighGesture = HandGestures.A;
                targetHand.HighGestureAccuracy = handAccuracy;

                if (evulAccuracy > fistAccuracy)
                {
                    targetHand.LowGesture = HandGestures.B;
                    targetHand.LowGestureAccuracy = evulAccuracy;
                }
                else
                {
                    targetHand.LowGesture = HandGestures.Neutral;
                    targetHand.LowGestureAccuracy = fistAccuracy;
                }

                return true;
            }
            else if (fistAccuracy >= evulAccuracy)
            { // fist is highest
                targetHand.HighGesture = HandGestures.Neutral;
                targetHand.HighGestureAccuracy = fistAccuracy;

                if (handAccuracy > evulAccuracy)
                {
                    targetHand.LowGesture = HandGestures.A;
                    targetHand.LowGestureAccuracy = handAccuracy;
                }
                else
                {
                    targetHand.LowGesture = HandGestures.B;
                    targetHand.LowGestureAccuracy = evulAccuracy;
                }

                return true;
            }
            else
            { // evul is highest
                targetHand.HighGesture = HandGestures.B;
                targetHand.HighGestureAccuracy = evulAccuracy;

                if (handAccuracy > fistAccuracy)
                {
                    targetHand.LowGesture = HandGestures.A;
                    targetHand.LowGestureAccuracy = handAccuracy;
                }
                else
                {
                    targetHand.LowGesture = HandGestures.Neutral;
                    targetHand.LowGestureAccuracy = fistAccuracy;
                }

                return true;
            }

            // TODO
            //return false;
        }

        private static int counter = 500;
        private static short[] handCollection;
        private static HandGestures targeteGesture;
        public static void LearnGestureEvent(bool isRight, short[] resizedHandArray)
        {
            if (counter >= 500)
                return;

            // TODO: should probably save a list somewhere...
            for (int i = 0; i < resizedHandArray.Length; ++i)
            {
                if (resizedHandArray[i] > 500)
                {
                    ++handCollection[i];
                }
            }

            ++counter;
            Debugging.ShowHand(resizedHandArray, PicWidth, PicHeight);
            
            if (counter == 500)
            {
                string resizedArrayString = "";

                foreach (short mineIsShort in handCollection)
                {
                    if (mineIsShort < 76)
                        resizedArrayString += ", " + 0;
                    else if (mineIsShort > 250)
                        resizedArrayString += ", " + 1000;
                    else
                        resizedArrayString += ", " + 500;
                }

                // TODO: Breakpoint here! we don´t save array yet!
            }
        }

        public static void SetLearnGesture(HandGestures newTargetGesture)
        {
            counter = 0;
            handCollection = new short[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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cheroo()
        {
            string reversies = "";

            for (int y = 0; y < PicHeight; ++y)
            {
                for (int x = PicWidth-1; x >= 0; --x)
                {
                    int originalIndex = 0;
                    originalIndex += y * PicWidth;
                    originalIndex += x;

                    // TODO: original gesture data goes here
                    //reversies += rightPointDefault[originalIndex] + ", ";
                }
            }

            // TODO: Breakpoint here since this is just crappy debug code
        }
    }
}
